package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ExpandAnArrayByAddingOneElementToTheEnd {
	static public short[] expandArray(short[] src) {
		return expandArray(src, 1);
	}

	static public short[] expandArray(short[] src, int expandBy) {
		short[] dst;
		if (src == null) {
			dst = new short[expandBy];
		} else {
			int n = src.length;
			dst = new short[n + expandBy];
			for (int j = 0; j < n; ++j) {
				dst[j] = src[j];
			}
		}
		return dst;
	}

	static public short[][] expandArray(short[][] src) {
		return expandArray(src, 1);
	}

	static public short[][] expandArray(short[][] src, int expandBy) {
		short[][] dst;
		if (src == null) {
			dst = new short[expandBy][];
		} else {
			int n = src.length;
			dst = new short[n + expandBy][];
			for (int j = 0; j < n; ++j) {
				dst[j] = src[j];
			}
		}
		return dst;
	}

	static public int[] expandArray(int[] src) {
		return expandArray(src, 1);
	}

	static public int[] expandArray(int[] src, int expandBy) {
		int[] dst;
		if (src == null) {
			dst = new int[expandBy];
		} else {
			int n = src.length;
			dst = new int[n + expandBy];
			for (int j = 0; j < n; ++j) {
				dst[j] = src[j];
			}
		}
		return dst;
	}

	static public long[] expandArray(long[] src) {
		return expandArray(src, 1);
	}

	static public long[] expandArray(long[] src, int expandBy) {
		long[] dst;
		if (src == null) {
			dst = new long[expandBy];
		} else {
			int n = src.length;
			dst = new long[n + expandBy];
			for (int j = 0; j < n; ++j) {
				dst[j] = src[j];
			}
		}
		return dst;
	}

	static public float[] expandArray(float[] src) {
		return expandArray(src, 1);
	}

	static public float[] expandArray(float[] src, int expandBy) {
		float[] dst;
		if (src == null) {
			dst = new float[expandBy];
		} else {
			int n = src.length;
			dst = new float[n + expandBy];
			for (int j = 0; j < n; ++j) {
				dst[j] = src[j];
			}
		}
		return dst;
	}

	static public double[] expandArray(double[] src) {
		return expandArray(src, 1);
	}

	static public double[] expandArray(double[] src, int expandBy) {
		double[] dst;
		if (src == null) {
			dst = new double[expandBy];
		} else {
			int n = src.length;
			dst = new double[n + expandBy];
			for (int j = 0; j < n; ++j) {
				dst[j] = src[j];
			}
		}
		return dst;
	}

	static public String[] expandArray(String[] src) {
		return expandArray(src, 1);
	}

	static public String[] expandArray(String[] src, int expandBy) {
		String[] dst;
		if (src == null) {
			dst = new String[expandBy];
		} else {
			int n = src.length;
			dst = new String[n + expandBy];
			for (int j = 0; j < n; ++j) {
				dst[j] = src[j];
			}
		}
		return dst;
	}
}
